package ch.reevolt.curchod.model;

import javax.swing.table.AbstractTableModel;

public class SearchModel extends AbstractTableModel {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7700547677428989157L;

	public static enum ModelType {
		TOOL, EMPLOYEE, IN_OUT, POSITION_STOCK, POSITION_OUT
	}

	private String[] header = new String[6];;
	private String[][] content = { { "", "", "", "", "", "" } };

	public SearchModel() {
		super();
		setType(ModelType.EMPLOYEE);
	}

	public void setType(ModelType type) {
		System.out.println("----> " + type);
		switch (type) {
		case TOOL:
			header[0] = "Prénom";
			header[1] = "Nom";
			header[2] = "Entrée / Sortie";
			header[3] = "Date";
			header[4] = "";
			header[5] = "";
			break;
		case EMPLOYEE:
			header[0] = "Nom";
			header[1] = "Déscription";
			header[2] = "Entrée / Sortie";
			header[3] = "Date";
			header[4] = "";
			header[5] = "";
			break;
		case IN_OUT:
			header[0] = "Prénom";
			header[1] = "Nom";
			header[2] = "Outil";
			header[3] = "Déscription";
			header[4] = "Entrée / Sortie";
			header[5] = "Date";
			break;
		case POSITION_STOCK:
			header[0] = "Nom";
			header[1] = "Déscription";
			header[2] = "";
			header[3] = "";
			header[4] = "";
			header[5] = "";
			break;
		case POSITION_OUT:
			header[0] = "Prénom";
			header[1] = "Nom";
			header[2] = "Outils";
			header[3] = "Déscription";
			header[4] = "Date";
			header[5] = "";
			break;
		default:
		}
		this.fireTableStructureChanged();
		this.fireTableDataChanged();
	}

	public SearchModel(String[][] content) {
		super();
		this.content = content;
	}

	public void setContent(String[][] content) {
		this.content = content;
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		return content[rowIndex][columnIndex];
	}

	@Override
	public int getColumnCount() {
		return header.length;
	}

	@Override
	public int getRowCount() {
		return content.length;
	}

	@Override
	public String getColumnName(int columnIndex) {
		return header[columnIndex];
	}
}
